﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>{$reply['title']}</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1.0,user-scalable=no">
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE">
<meta name="robots" content="index,follow" />
<link rel="stylesheet" type="text/css" href="../addons/stonefish_redenvelope/template/css/al_base.css">
<link href="../addons/stonefish_redenvelope/template/css/emoji.css" rel="stylesheet" type="text/css" />
	<style>
	body {
	background: {$reply['bgcolor']};
	color: {$reply['fontcolor']};
}
.btnLink {
	background: {$reply['btncolor']};
	color: {$reply['btnfontcolor']};
}
a:link,a:visited,a:hover,a:active {color:{$reply['btnfontcolor']};}
.money .btnLink,.money1 .btnLink {
	background: {$reply['txcolor']};
	color: {$reply['txfontcolor']};
}
.wrap .helpLink {
	background: {$reply['txcolor']};
	color: {$reply['txfontcolor']};
}
	.cardList .card .back {
	 background: url({if $reply['cardbg']}{$_W['attachurl']}{$reply['cardbg']}{else}{php echo $this->cardbg();}{/if});
	background-size: 100% 100%
	}
	.text {
	border: 1px solid {$reply['rulebgcolor']};
	background: {$reply['rulebgcolor']};
}
	</style>
</head>
<body>
	<div style="max-width:100%">
		{if !empty($reply['adpic'])}{if !empty($reply['adpicurl'])}<a href="{$reply['adpicurl']}">{/if}<img id="top_img" style="max-width: 100%;height: auto;width: auto\9;"  src="{php echo toimage($reply['adpic'])}" width="100%" border="0">{if !empty($reply['adpicurl'])}</a>{/if}{/if}
    </div> 
	<div class="wrap">
		<div class="cardList">
			<div class="tipClick"></div>
			<div class="rotatoText">你为Ta翻的奖金是...</div>
			<div class="resultText">
				<span id="price_tip_msg"></span> <span>帮&nbsp;<label class="nickname">{$fans['nickname']}</label>&nbsp;抽得了
					<label id="prizeResult"></label>元现金券
				</span>
			</div>
			<div class="card card_01">
				<div class="front">
					<span class="price price_50"></span>
				</div>
				<div class="back"></div>
			</div>
			<div class="card card_02">
				<div class="front">
					<span class="price price_100"></span>
				</div>
				<div class="back"></div>
			</div>
			<div class="card card_03">
				<div class="front">
					<span class="price price_150"></span>
				</div>
				<div class="back"></div>
			</div>
			<div class="card card_04">
				<div class="front">
					<span class="price price_200"></span>
				</div>
				<div class="back"></div>
			</div>
			<div class="card card_05">
				<div class="front">
					<span class="price price_300"></span>
				</div>
				<div class="back"></div>
			</div>
			<div class="card card_06">
				<div class="front">
					<span class="price price_500"></span>
				</div>
				<div class="back"></div>
			</div>
		</div>

		<div class="shareAll" style="display: none">
			<div class="text">
				<span>你帮好友 <label class="name nickname">{$fans['nickname']}</label>
					攒到 <label id="prizeMoney"></label> 元，炫耀一下吧!
				</span>
			</div>
			<a href="javascript:;" class="btnLink" id="randomPrize" clickGoal="0">{$reply['fsharebtn']}</a>
			<a href="{php echo $this->createMobileUrl('userredenvelope',array('rid'=>$rid,'uid'=>$fans['id']))}" class="btnLink" >去瞅瞅{$fans['nickname']}的钱包</a>
			<a href="javascript:;" class="btnLink" id="btn_agin"></a>
		</div>
		<div class="text">{$reply['fanpaitip']}</div>
		{if !$firendExists}<a class="btnLink" href="{php echo $this->createMobileUrl('index',array('rid'=>$rid))}">我也要领红包</a>{/if} 
		{if $firendExists} <a href="{php echo $this->createMobileUrl('index',array('rid'=>$rid))}" class="btnLink">去瞅瞅我的钱包</a>{/if}
	</div>
	<div class="maskTip" id="shareToFriends">
		<div class="mask"></div>
		<div class="con_2">
			<div class="tipText"></div>
			<p><img src="{php echo toimage($share['share_pic'])}" width="100%"></p>
			<a href="javascript:;" class="btnLink" id="Close">确定</a>			
		</div>
	</div>
	<div class="maskTip" style="display:none;" id="rePrizeErrorDiv">
		<div class="mask"></div>
		<div class="con_1">
			<div class="tipText"><p id="errorText"></p></div>				
			<a href="{php echo $this->createMobileUrl('userredenvelope',array('rid'=>$rid,'uid'=>$fans['id']))}" class="btnLink" id="rep_ok" >去瞅瞅{$fans['nickname']}的钱包</a>
			{if !$firendExists}<a class="btnLink" href="{php echo $this->createMobileUrl('index',array('rid'=>$rid))}">我也要领红包</a>{/if} 
			{if $firendExists} <a href="{php echo $this->createMobileUrl('index',array('rid'=>$rid))}" class="btnLink">去瞅瞅我的钱包</a>{/if}			  
		</div>
	</div>
	<script type="text/javascript" src="../addons/stonefish_redenvelope/template/js/zepto.min.js"></script>
	<script src="../addons/stonefish_redenvelope/template/js/emoji.js"></script>	
	<script>    
	$(function() {	  
		  $("#shareGuid").click(function() {
		        $(".maskTip").show()
		    });
		    $("#Close").click(function() {
		        $(".maskTip").hide()
		    });		
	  		var allow="{$allow}";	  		
	  		if(allow){	  			
	  		  $("#Close").click(function() {		        	
		            $(".maskTip").hide()
		        });		        
		        $("#randomPrize").click(function() {
		            $("#shareToFriends").show()
		        });
		        $("#btn_agin").click(function(){
		        	location.reload();
		        });		        
		        function init() {        	
		            $(".tipClick,.rotatoText,.resultText,.shareAll").hide();
		            $(".cardList .card").removeClass("flip");
		            setTimeout(function() {
		                $(".tipClick").fadeIn(300, function() {
		                    setTimeout(function() {
		                        $(".tipClick").fadeOut(500)
		                    }, 4000)
		                })
		            }, 1000);
		        }		        
		        var rotatoResult;
		        function getMoneyResult() {
		            setTimeout(function() {
		                clearInterval(rotatoResult);
		                $(".flipover").addClass("flip");
		                $(".rotatoText").hide();
		                $(".resultText,.shareAll").show(400);
		                $("#randomPrize").removeClass("prizing")
		            }, 2000)
		        }	        
		        $(".cardList .card").click(function() {
		            if ($("body").hasClass("done")) {
		               // $("#rePrizeErrorDiv").show();
		                return
		            } else {
		                if ($(this).hasClass("flipover")) {
		                    return
		                }
		                $(this).addClass("flipover");
		                var _self = $(this);
		                setTimeout(function() {
		                    $(".cardList .card").each(function() {
		                        if (!$(this).hasClass("flipover")) {
		                            $(this).fadeOut(200)
		                        }
		                    });
		                    _self.addClass("togetherResult").find(".back").css({width: 110,height: 155}, 600);
		                    $(".rotatoText").show();
		                    rotatoResult = setInterval(function() {
		                        _self.addClass("rotatoOver");
		                        setTimeout(function() {
		                            _self.removeClass("rotatoOver")
		                        }, 150)
		                    }, 300)
		                }, 500);
						
		                $.ajax({type: "POST",url:"{php echo $this->createMobileUrl('FirendFanpai',array('rid'=>$rid,'uid'=>$fans['id']))}",data: {fopenid: "{$firend['openid']}",fnickname: "{$firend['nickname']}",fheadUrl:"{$firend['headimgurl']}"},dataType: "json",async: true,timeout: 3000,success: function(data) {
		                	if(data.code==200){
		                		 $(".cardList .price").removeClass("price_50 price_100 price_150 price_200 price_300 price_500");
		                          // $(".cardList .price").addClass("price_" + data.result);
		                          // $(".cardList .price").removeClass("price");
		                          $(".cardList .price").html(data.result);
		                            $("#prizeResult").html(data.result);
		                            $("#prizeMoney").html(data.result);
		                            getMoneyResult();
		                            
		                            var left=data.left;
		                            var msg="恭喜您!";
		                            if(data.result<0){
		                            	msg="糗大了！"
		                            }		                            
		                            $("#price_tip_msg").html(msg);
		                            if(left>0){
		                            	$("#btn_agin").html("你还可以帮好友翻牌"+left+"次");
		                            	$("#btn_agin").show();
		                            }else{
		                            	$("#btn_agin").hide();
		                            }
		                	}else{
		                		$("#errorText").html(data.msg);
		                		 $("#rePrizeErrorDiv").show();
		                	}
		                    },error: function(xhr, type) {
		                        alert("发送网络请求失败！")
		                    }});
		            }
		            //$("body").addClass("done")
		        });
		        init()
	  		}else{
	  			$("#errorText").html("{$msg}");
	  			$("#rePrizeErrorDiv").show();
	  		}		
	});
		$(function() {
			// 微信昵称特殊字符处理
			$(".nickname").each(function() {
				var html = $(this).html().trim().replace(/\n/g, '<br/>');
				html = jEmoji.softbankToUnified(html);
				html = jEmoji.googleToUnified(html);
				html = jEmoji.docomoToUnified(html);
				html = jEmoji.kddiToUnified(html);
				$(this).html(jEmoji.unifiedToHTML(html));
			});
		});
	</script>
{template 'jssdk'}
</body>
</html>